
const mongoose = require('mongoose')
const { Schema } = mongoose

// 字段
const HeroSchema = new Schema({
    name: { type: String },
    avatar: { type: String },
    banner: { type: String },
    title: { type: String },
    categories: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'Category' }],
    scores: {
        difficult: {type: Number},
        skill: {type: Number},
        attack: {type: Number},
        survive: {type: Number},
    },
    skills: [{
        icon: { type: String },
        name: { type: String },
        description: { type: String },
        tips: { type: String },
    }],
    item1: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'Item' }],
    item2: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'Item' }],
    usageTips: { type: String },
    battleTips: { type: String },
    teamTips: { type: String },
    partners: [{ 
        hero: { type: mongoose.SchemaTypes.ObjectId, ref: 'Hero' },
        description: { type: String }
    }]
})

// 模型
const HeroModel = mongoose.model('Hero', HeroSchema, 'heroes')

// 导出
module.exports = HeroModel